//
//  DataDictionaryDataSourceProtocolTests.swift
//  DataSourceLib
//
//  Created by green on 15/11/6.
//  Copyright © 2015年 CocoaPods. All rights reserved.
//

import XCTest
import TMDatasourceLib
import TMCommonLib

class DataDictionaryDataSourceProtocolTests: XCTestCase {
    
    var dataDictionaryDataSourceProtocol: DataDictionaryDataSourceProtocol!
    
    override func setUp() {
        super.setUp()
        
        dataDictionaryDataSourceProtocol = DataDictionaryDataSource.shareInstance()
    }
    
    override func tearDown() {
        // Put teardown code here. This method is called after the invocation of each test method in the class.
        super.tearDown()
    }
    
    /**
     统计数据字典列表记录总和测试
     */
    func testQueryDataDictionaryCount() {
        
        let totalCount = dataDictionaryDataSourceProtocol.queryDataDictionaryTotalCount()
        print("\ncurrent total count is \(totalCount)\n")
        
    }
    
    /**
     清空数据字典列表数据测试
     */
    func testClearDataDictionaryList() {
        
        dataDictionaryDataSourceProtocol.clearDataDictionaryList()
        
        let totalCount = dataDictionaryDataSourceProtocol.queryDataDictionaryTotalCount()
        print("\ncurrent total count is \(totalCount)\n")
        XCTAssert(totalCount == 0, "clear data dictionary failure")
    }
    
    /**
     初始化数据字典列表测试
     */
    func testSetDataDictionaryList() {
        
        dataDictionaryDataSourceProtocol.clearDataDictionaryList()
        dataDictionaryDataSourceProtocol.setUpDataDictionaryList()
        let monthTotalCount         = dataDictionaryDataSourceProtocol.queryDataDictionaryCount(.Month)
        let poiLevelTotalCount      = dataDictionaryDataSourceProtocol.queryDataDictionaryCount(.POILevel)
        let poiTypeTotalCount       = dataDictionaryDataSourceProtocol.queryDataDictionaryCount(.POIType)
        let strategyOrderTotalCount = dataDictionaryDataSourceProtocol.queryDataDictionaryCount(.StrategyOrder)
        let strategyThemeTotalCount = dataDictionaryDataSourceProtocol.queryDataDictionaryCount(.StrategyTheme)
        let strategyTypeTotalCount  = dataDictionaryDataSourceProtocol.queryDataDictionaryCount(.StrategyType)
        
        XCTAssert(monthTotalCount==12, "initial month data list failure")
        XCTAssert(poiLevelTotalCount==5, "initial poi level data list failure")
        XCTAssert(poiTypeTotalCount==5, "initial poi type data list failure")
        XCTAssert(strategyOrderTotalCount==5, "initial strategy order data list failure")
        XCTAssert(strategyThemeTotalCount==15, "initial strategy theme data list failure")
        XCTAssert(strategyTypeTotalCount==5, "initial strategy type data list failure")
        
    }
    
    /**
     查询数据字典列表测试
     */
    func testQueryDataDictionaryList() {
        
        let monthDataList         = dataDictionaryDataSourceProtocol.queryDataDictionaryList(.Month)
        print("current month data list is \(monthDataList)")
    }
    
    /**
     查询数据字典列表测试
     */
    func testQueryDataDictionaryCountByType() {
        
        let poiTypeTotalCount         = dataDictionaryDataSourceProtocol.queryDataDictionaryCount(.POIType)
        print("current poi type data list count is \(poiTypeTotalCount)")
    }
    
}
